package com.moli.iov.handle.alarm.notice;

import com.moli.iov.notify.enums.MessageTypeEnum;
import com.moli.iov.notify.model.dto.NoticeMessageCenterDto;
import com.moli.iov.notify.remote.INoticeMessageCenterRemoteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 报警通知
 * </p>
 *
 * @author zql
 * @since 2019/10/14 16:29
 */
@Slf4j
@Component
public class AlarmNotice {

  @Autowired
  private INoticeMessageCenterRemoteService noticeMessageCenterRemoteService;

  /**
   * 报警通知
   * @param vin
   * @param alarmCode
   */
  @Async
  public void trigger(String vin, Integer alarmCode){
    NoticeMessageCenterDto noticeMessageCenterDto = new NoticeMessageCenterDto();
    noticeMessageCenterDto.setMessageSource(alarmCode);
    noticeMessageCenterDto.setVin(vin);
    noticeMessageCenterDto.setMessageType(MessageTypeEnum.ALARM.getMessageCode());
    noticeMessageCenterRemoteService.trigger(noticeMessageCenterDto);
  }
}
